﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterCustomerLogin.master" AutoEventWireup="true" CodeBehind="ShowOrderList.aspx.cs" Inherits="UdrinkWater_Project.Customer.ShowOrderList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <dx:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" 
        HeaderText="รายการสั่งซื้อ" Width="100%">
        <HeaderStyle Font-Size="Large" />
        <PanelCollection>
            <dx:PanelContent runat="server" SupportsDisabledAttribute="True">
                <asp:Panel ID="Panel3" runat="server">
                    <fieldset><legend>รายการสั่งซื้อ</legend>
                    <table style="width: 100%">
                        <tr>
                            <td width="10%">
                                <dx:ASPxLabel ID="ASPxLabel4" runat="server" Text="วันที่">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%; height: 32px;" width="40%">
                                <dx:ASPxTextBox ID="txtDate" runat="server" BackColor="#D3E4A6" ReadOnly="True" 
                                    Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td width="10%">
                                <dx:ASPxLabel ID="ASPxLabel11" runat="server" Text="วันที่ส่ง" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%; height: 32px;">
                                <dx:ASPxTextBox ID="txtShipp" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;">
                                <dx:ASPxLabel ID="ASPxLabel5" runat="server" Text="รหัสลูกค้า" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtCustomer" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                            <td style="width: 0%">
                                <dx:ASPxLabel ID="ASPxLabel3" runat="server" Text="ชื่อลูกค้า" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <dx:ASPxTextBox ID="txtCustomerName" runat="server" BackColor="#D3E4A6" 
                                    ReadOnly="True" Width="250px">
                                </dx:ASPxTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                &nbsp;</td>
                            <td style="width: 25%">
                                <dx:ASPxRadioButtonList ID="rbtChooseAddres" runat="server" AutoPostBack="True" 
                                    OnSelectedIndexChanged="rbtChooseAddres_SelectedIndexChanged" 
                                    RepeatDirection="Horizontal" SelectedIndex="0">
                                    <Items>
                                        <dx:ListEditItem Selected="True" Text="จัดส่งตามที่อยู่เดิม" Value="0" />
                                        <dx:ListEditItem Text="แก้ไขที่อยู่จัดส่ง" Value="1" />
                                    </Items>
                                </dx:ASPxRadioButtonList>
                            </td>
                            <td style="width: 0%" width="50%">
                                &nbsp;</td>
                            <td style="width: 25%" width="50%">
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel13" runat="server" Text="ที่อยู่จัดส่ง" 
                                    Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                        <dx:ASPxTextBox ID="txtAdress" runat="server" BackColor="#D3E4A6" 
                                            ReadOnly="True" Width="250px">
                                        </dx:ASPxTextBox>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="rbtChooseAddres" 
                                            EventName="SelectedIndexChanged" />
                                    </Triggers>
                                </asp:UpdatePanel>
                            </td>
                            <td style="width: 0%" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel12" runat="server" Text="จังหวัด" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%" width="50%">
                                <asp:UpdatePanel ID="UpdatePanel4" runat="server">
                                    <ContentTemplate>
                                        <dx:ASPxComboBox ID="ASPxComboBox1" runat="server" AutoPostBack="True" 
                                            BackColor="#D3E4A6" DataSourceID="SqlDataSource1" 
                                            OnSelectedIndexChanged="ASPxComboBox1_SelectedIndexChanged" ReadOnly="True" 
                                            TextField="PROVINCE_NAME" ValueField="PROVINCE_ID" ValueType="System.Int32">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            SelectCommand="SELECT * FROM [TB_Province] ORDER BY [PROVINCE_NAME]">
                                        </asp:SqlDataSource>
                                    </ContentTemplate>
                                    <Triggers>
                                        <asp:AsyncPostBackTrigger ControlID="rbtChooseAddres" 
                                            EventName="SelectedIndexChanged" />
                                    </Triggers>
                                </asp:UpdatePanel>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel14" runat="server" Text="อำเภอ" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                    <ContentTemplate>
                                        <dx:ASPxComboBox ID="ASPxComboBox2" runat="server" AutoPostBack="True" 
                                            BackColor="#D3E4A6" DataSourceID="SqlDataSource2" 
                                            OnSelectedIndexChanged="ASPxComboBox2_SelectedIndexChanged" ReadOnly="True" 
                                            TextField="AMPHUR_NAME" ValueField="AMPHUR_ID" ValueType="System.Int32">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            SelectCommand="SELECT * FROM [TB_Aumphur] WHERE ([PROVINCE_ID] = @PROVINCE_ID) ORDER BY [AMPHUR_NAME]">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="ASPxComboBox1" Name="PROVINCE_ID" 
                                                    PropertyName="Value" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                            <td style="width: 0%" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel15" runat="server" Text="ตำบล" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%" width="50%">
                                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                    <ContentTemplate>
                                        <dx:ASPxComboBox ID="ASPxComboBox3" runat="server" BackColor="#D3E4A6" 
                                            DataSourceID="SqlDataSource3" ReadOnly="True" TextField="DISTRICT_NAME" 
                                            ValueField="DISTRICT_ID" ValueType="System.Int32">
                                        </dx:ASPxComboBox>
                                        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                                            ConnectionString="<%$ ConnectionStrings:DB_Udrink %>" 
                                            SelectCommand="SELECT * FROM [TB_District] WHERE ([AMPHUR_ID] = @AMPHUR_ID) ORDER BY [DISTRICT_NAME]">
                                            <SelectParameters>
                                                <asp:ControlParameter ControlID="ASPxComboBox2" Name="AMPHUR_ID" 
                                                    PropertyName="Value" Type="Int32" />
                                            </SelectParameters>
                                        </asp:SqlDataSource>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 0%; height: 32px;" width="50%">
                                <dx:ASPxLabel ID="ASPxLabel16" runat="server" Text="รหัสไปรษณีย์" Width="100px">
                                </dx:ASPxLabel>
                            </td>
                            <td style="width: 25%">
                                <asp:UpdatePanel ID="UpdatePanel5" runat="server">
                                    <ContentTemplate>
                                        <dx:ASPxTextBox ID="txtZipCode" runat="server" BackColor="#D3E4A6" 
                                            ReadOnly="True" style="margin-top: 12px" Width="250px">
                                        </dx:ASPxTextBox>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                            <td style="width: 0%" width="50%">
                                &nbsp;</td>
                            <td style="width: 25%" width="50%">
                                &nbsp;</td>
                        </tr>
                    </table>
                     </fieldset>
                </asp:Panel>
                <asp:Panel ID="Panel1" runat="server">
                    <fieldset>
                        <legend>รายการสินค้า</legend>
                    <dx:ASPxGridView ID="GV_OrderList" runat="server" AutoGenerateColumns="False" 
            Width="100%" Font-Size="Medium"  KeyFieldName="Number"
            oncustomunboundcolumndata="GV_OrderList_CustomUnboundColumnData" 
            onrowcommand="GV_OrderList_RowCommand" >
           <TotalSummary>
<dx:ASPxSummaryItem SummaryType="Sum" FieldName="TotalRow" DisplayFormat="รวม {0:#,###.00}"></dx:ASPxSummaryItem>
           </TotalSummary>
        <Columns>
            <dx:GridViewDataTextColumn FieldName="Goods_ID" VisibleIndex="1" 
                Caption="รหัสสินค้า">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Goos_Name" VisibleIndex="2" 
                Caption="สินค้า">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Price" VisibleIndex="4" Caption="ราคา">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="PriceNumber" VisibleIndex="5" 
                Caption="จำนวนสินค้า">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="รายการ" VisibleIndex="0" 
                UnboundType="String" FieldName="Number">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
                <DataItemTemplate>
            <%#Container.ItemIndex +1 %> 
                </DataItemTemplate>

            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="TotalRow" UnboundType="Decimal" 
                VisibleIndex="7" Caption="รวม"> 
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Right">
                </CellStyle>
                <FooterCellStyle ForeColor="Black" HorizontalAlign="Right" />
               
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="ส่วนลด" FieldName="Discount" 
                VisibleIndex="6">
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn VisibleIndex="9">
                <DataItemTemplate>
                     <dx:ASPxButton ID="btnImageAndText" runat="server" CommandName="Cmd_Delete"  CommandArgument='<%# Container.ItemIndex %>' 
                Width="120px" Text="ลบรายการ" BackColor="White" >
                <Image Url="../images/Remove.png" Width="16px" Height="16px"></Image>
                <ClientSideEvents Click="function(s,e) { e.processOnServer = confirm('Are you sure?'); }" />
            </dx:ASPxButton>
                </DataItemTemplate>
                <HeaderStyle HorizontalAlign="Center" />
                <CellStyle HorizontalAlign="Center">
                </CellStyle>
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="หน่วย" FieldName="Unit" 
                ShowInCustomizationForm="True" VisibleIndex="3">
            </dx:GridViewDataTextColumn>
        </Columns>
        <Settings ShowFooter="True" ShowGroupFooter="VisibleIfExpanded" />
        
           <SettingsBehavior ConfirmDelete="True" />
        
           <SettingsPager Mode="ShowAllRecords" >
           </SettingsPager>
           <SettingsText ConfirmDelete="ยืนยันการลบข้อมูล" />
    </dx:ASPxGridView> 
    </fieldset>
                </asp:Panel>
                <asp:Panel ID="Panel2" runat="server">
                    <table style="width: 100%">
                        <tr>
                            <td align="right" width="45%">
                                <dx:ASPxButton ID="btSubmit" runat="server" OnClick="btSubmit_Click" 
                                    Text="ยืนยันการสั่งซื้อ" Width="100px">
                                    <ClientSideEvents Click="function(s, e) {
	e.processOnServer = confirm('ยืนยันรายการสั่งซื้อ?');
}" />
                                </dx:ASPxButton>
                            </td>
                            <td width="10%" align="center">
                                <dx:ASPxButton ID="ASPxButton1" runat="server" OnClick="ASPxButton1_Click" 
                                    Text="เลือกสินค้าเพิ่ม">
                                </dx:ASPxButton>
                            </td>
                            <td width="45%">
                                <dx:ASPxButton ID="btCancle" runat="server" Text="ยกเลิก" 
                                    OnClick="btCancle_Click" Width="100px">
                                    <ClientSideEvents Click="function(s, e) {
	e.processOnServer = confirm('ต้องยกเลิกรายการสั่งซื้อหรือไม่? ข้อแนะนำ:ถ้าใช่ สินค้าในรายการจะโดนลบ!');
}" />
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                    
                </asp:Panel>
            </dx:PanelContent>
        </PanelCollection>
    </dx:ASPxRoundPanel>
</asp:Content>
